#include <vector>
#include <queue>
#include "../common/TreeNode.h"

using namespace std;

/* 层序遍历 */
vector<int> levelOrder(TreeNode* root) {
    queue<TreeNode*> queue;
    queue.push(root);
    vector<int> vec;
    while (!queue.empty()) {
        TreeNode* node = queue.front();
        queue.pop();
        vec.push_back(node->val);
        if (node->left != nullptr)
            queue.push(node->left);
        if (node->right != nullptr)
            queue.push(node->right);
    }
    return vec;
}
